package com.xysoft.admin;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import com.xysoft.ServiceLocator;
import com.xysoft.admin.service.IHomeService;

public class SessionListener implements HttpSessionListener {
//    private SessionContext myc = SessionContext.getInstance();
    private static IHomeService homeService;
    
    public IHomeService getHomeService() {
    	if (homeService == null) {
    		homeService = ServiceLocator.getService(IHomeService.class);
    	}
    	return homeService;
    }
    
    public void sessionCreated(HttpSessionEvent httpSessionEvent) {
        //myc.AddSession(httpSessionEvent.getSession());
    }
    public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
    	HttpSession session = httpSessionEvent.getSession();
    	getHomeService().logout(session);
        //myc.DelSession(session.getId());
    }
}
